﻿// <copyright file="MapPhotoPanel.xaml.cs" company="Taasss">Copyright (c) 2009 All Right Reserved</copyright>
// <author>Ben Vincent</author>
// <date>2010-02-21</date>
// <summary>MapPhotoPanel</summary>
namespace Fotofly.PhotoViewer
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Browser;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;

    public partial class MapPhotoPanel : UserControl
    {
        private double fullWidth;
        private double fullHeight;
        private double iconWidth;
        private double iconHeight;

        public MapPhotoPanel(Uri imageUri, double imageWidth, double imageHeight)
        {
            this.InitializeComponent();

            this.fullWidth = imageWidth * 1.4;
            this.fullHeight = imageHeight * 1.4;

            this.iconWidth = imageWidth * 0.2;
            this.iconHeight = imageHeight * 0.2;

            this.catalogImage.Source = new BitmapImage(imageUri);

            this.catalogImage.Width = this.iconWidth;
            this.catalogImage.Height = this.iconHeight;

            this.Width = this.iconWidth;
            this.Height = this.iconHeight;
        }

        public Uri OnClickUri
        {
            get;
            set;
        }

        private void LayoutRoot_MouseEnter(object sender, MouseEventArgs e)
        {
            this.catalogImage.Width = this.fullWidth;
            this.catalogImage.Height = this.fullHeight;
            this.SetValue(Canvas.ZIndexProperty, 100);
        }

        private void LayoutRoot_MouseLeave(object sender, MouseEventArgs e)
        {
            this.catalogImage.Width = this.iconWidth;
            this.catalogImage.Height = this.iconHeight;
            this.SetValue(Canvas.ZIndexProperty, 10);
        }

        private void CatalogImageMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (this.OnClickUri != null)
            {
                HtmlPage.Window.Navigate(this.OnClickUri);
            }
        }
    }
}
